package test.day04;

public class AddTwoString {
	public String addStrings(String num1, String num2) {
		int carry = 0;
		StringBuilder s = new StringBuilder();
		int i = num1.length() - 1, j = num2.length() -1 ;
		while(i >= 0 || j >= 0 || carry != 0){
			int x = num1.charAt(i) - '0';
			int y = num2.charAt(i) - '0';
			int sum = (x + y) % 10;
			s.append(sum);
			carry = (carry + sum)/10;
		}
		if (carry > 0) {
			s.append(carry);
		}
		return s.reverse().toString();
	}
}
